package com.market.controller.admin;

import com.market.bean.MarketGoods;
import com.market.bean.MarketOrder;
import com.market.bean.MarketUser;
import com.market.bean.common.BaseRespVo;
import com.market.bean.common.CommonData;
import com.market.bean.vo.admin.AdminDashboardVo;

import com.market.service.admin.AdminGoodsProductService;
import com.market.service.admin.AdminGoodsService;
import com.market.service.admin.AdminOrderService;
import com.market.service.admin.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author tan
 * @date 2022年12月30日 23:36
 */
@RestController
@RequestMapping("admin")
public class AdminDashboardController {
    @Autowired
    AdminGoodsService goodsService;
    @Autowired
    AdminUserService userService;
    @Autowired
    AdminOrderService orderService;
    @Autowired
    AdminGoodsProductService goodsProductService;


    @RequestMapping("dashboard")
    public BaseRespVo dashboard() {
        CommonData<MarketGoods> goodsList = goodsService.list(null, null, null, null);
        Integer goodsTotal = goodsList.getTotal();
        CommonData<MarketUser> userList = userService.list(null, null, null);
        Integer userTotal = userList.getTotal();
        CommonData<MarketOrder> orderList = orderService.list(null, null, null, null, null, null, null);
        Integer orderTotal = orderList.getTotal();
        Long productTotal = goodsProductService.count();
        AdminDashboardVo data = new AdminDashboardVo(goodsTotal, userTotal, productTotal, orderTotal);
        return BaseRespVo.ok(data);
    }

}
